/**
 * ...
 * @author Thot
 */

function IsoUtils(){}
 
IsoUtils.prototype.screenToIso = function( p_x, p_y, p_cellW, p_cellH )
{
	//var l_coords:Point = new Point( 0, 0);
	
	//p_x -= p_nodeWidth * 0.5;
	
	/**
	 * 
	 * 	p_x = ( col - line ) * ( nodeWidth / 2 );
	 *	p_y = ( col + line ) * ( nodeHeight / 2 );
	 * 
	 *  ( col - line ) = p_x / ( nodeWidth / 2 );
	 *  ( col + line ) = p_y / ( nodeHeight / 2 );
	 * 
	 *   -2 * line = ( col - line ) - ( col + line ) = ( p_x / ( nodeWidth / 2 ) ) - ( p_y / ( nodeHeight / 2 ) );
	 *   line = ( ( p_x / ( nodeWidth / 2 ) ) - ( p_y / ( nodeHeight / 2 ) ) ) / -2;
	 *   
	 * 
	 *   2 * col = col - line + col + line = ( p_x / ( nodeWidth / 2 ) ) + ( p_y / ( nodeHeight / 2 ) );
	 *   col = ( ( p_x / ( nodeWidth / 2 ) ) + ( p_y / ( nodeHeight / 2 ) ) ) / 2
	 * 
	 * 
	 * 
	 */
	
	 var p_nodeHeight = p_cellW;
	 var p_nodeWidth = p_cellH;
	 
	var l_midHeight = p_nodeHeight >> 1;
	var l_midWidth = p_nodeWidth >> 1;
	
	p_x -= l_midWidth;
	
	var l_col = ( ( ( p_x / l_midWidth ) + ( p_y / l_midHeight ) ) * 0.5 ) << 0;
	var l_row = ( ( ( p_x / l_midWidth ) - ( p_y / l_midHeight ) ) * -0.5 ) << 0;
	
	return {"col":l_col, "row":l_row };
};

IsoUtils.prototype.isoToScreen = function(  p_row, p_col, p_cellW, p_cellH )
{
	var x = ( p_col - p_row ) * ( p_cellW * 0.5 );
	var y = ( p_col + p_row ) * ( p_cellH * 0.5 );
	
	return {"x":x, "y":y };
};

